﻿import idv.ben.gc4flash.chart.*;
import idv.ben.gc4flash.dataLine.*;
import idv.ben.gc4flash.encode.*;
import idv.ben.gc4flash.fill.*;
import idv.ben.gc4flash.style.*;
import idv.ben.gc4flash.util.*;
/**
* BarStyle，用來設定 {@link idv.ben.gc4flash.chart.BarChart} 樣式。<br>
*/
class idv.ben.gc4flash.style.BarStyle {
	private var barWidth:Number;
	private var barsSpace:Number;
	private var groupsSpace:Number;
	/**
	* 建構子
	* @param barWidth 每一筆長條資料的寬度
	* @param barsSpace optional，每一筆長條之間的距離
	* @param groupsSpace optional，每一組長條資料群組之間的距離
	*/
	function BarStyle(barWidth:Number, barsSpace:Number, groupsSpace:Number) {
		this.barWidth = barWidth;
		this.barsSpace = barsSpace;
		this.groupsSpace = groupsSpace;
	}
	/**
	* 取得長條圖的風格所組成的 URL 參數字串<br>
	* <br>
	* <table>
	* <tr>
	* <td><img src="http://chart.apis.google.com/chart?cht=bhs&chs=200x125&chd=s:hello"></td>
	* <td><img src="http://chart.apis.google.com/chart?cht=bhs&chs=200x125&chd=s:hello&chbh=10"></td>
	* </tr>
	* <tr>
	* <td>cht=bhs</td>
	* <td>cht=bhs&chbh=10</td>
	* </tr>
	* </table>
	* <br>
	* <table>
	* <tr>
	* <td><img src="http://chart.apis.google.com/chart?cht=bhg&chs=200x125&chd=s:elg,ors&chbh=10&chco=cc0000,00aa00"></td>
	* <td><img src="http://chart.apis.google.com/chart?cht=bhg&chs=200x125&chd=s:elg,ors&chbh=10,5,15&chco=cc0000,00aa00"></td>
	* <td><img src="http://chart.apis.google.com/chart?cht=bhg&chs=200x125&chd=s:elg,ors&chbh=10,8&chco=cc0000,00aa00"></td>
	* <td><img src="http://chart.apis.google.com/chart?cht=bhg&chs=200x125&chd=s:elg,ors&chbh=10,15&chco=cc0000,00aa00"></td>
	* </tr>
	* <tr>
	* <td>cht=bhg&chbh=10</td>
	* <td>cht=bvg&chbh=10,5,15</td>
	* <td>cht=bhg&chbh=10,8</td>
	* <td>cht=bhg&chbh=10,15</td>
	* </tr>
	* </table>
	* @return URL 參數字串
	**/
	public function toChartData():String {
		var chartData:Array;
		if(barsSpace == null){
			chartData = [barWidth];
		}else{
			if(groupsSpace == null){
				chartData = [barWidth, barsSpace];
			}else{
				chartData = [barWidth, barsSpace, groupsSpace];
			}
		}
		return chartData.join(",");
	}
}